package com.example.jixeishi1.service.impl;

import com.example.jixeishi1.dao.OrdersDao;
import com.example.jixeishi1.entity.Orders;
import com.example.jixeishi1.entity.cs1;
import com.example.jixeishi1.service.OrdersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Service
public class OrdersServiceimpl implements OrdersService {

    @Autowired
    OrdersDao dao;

    @Override
    public PageInfo statelist(int p, Orders orders) {
        PageInfo info = null;
        System.out.println("订单"+orders.getMarketorder());
        if(orders.getMarketorder()!=null){
            PageHelper.startPage(p,5);
            List list=dao.statelist1(orders);
             info=new PageInfo(list);
            int navnum[] = info.getNavigatepageNums();
            System.out.println("导航页="+ Arrays.toString(navnum));
//        System.out.println(list);
            System.out.println("总页:"+info.getPages());
            System.out.println("页:"+info.getPageNum());
            System.out.println("行:"+info.getTotal());
            System.out.println("数据:"+info.getList());
        }else{
            PageHelper.startPage(p,5);
            List list=dao.statelist(orders);
            info=new PageInfo(list);
            int navnum[] = info.getNavigatepageNums();
            System.out.println("导航页="+ Arrays.toString(navnum));
//        System.out.println(list);
            System.out.println("总页:"+info.getPages());
            System.out.println("页:"+info.getPageNum());
            System.out.println("行:"+info.getTotal());
            System.out.println("数据:"+info.getList());
        }
        return info;

    }

    @Override
    public PageInfo infostate(int p,Orders orders) {
        PageHelper.startPage(p,5);
        List list=dao.infostate(orders);
        PageInfo info=new PageInfo(list);
        int navnum[] = info.getNavigatepageNums();
        System.out.println("导航页="+ Arrays.toString(navnum));
//        System.out.println(list);
        System.out.println("总页:"+info.getPages());
        System.out.println("页:"+info.getPageNum());
        System.out.println("行:"+info.getTotal());
        System.out.println("数据:"+info.getList());
        return info;
    }

    @Override
    public PageInfo ssstate(int p, Map map) {
        PageHelper.startPage(p,5);
        List list=dao.ssstelist(map);
        PageInfo info=new PageInfo(list);
        int navnum[] = info.getNavigatepageNums();
        System.out.println("导航页="+ Arrays.toString(navnum));
        System.out.println("总页:"+info.getPages());
        System.out.println("页:"+info.getPageNum());
        System.out.println("行:"+info.getTotal());
        System.out.println("数据:"+info.getList());
        return info;
    }

    @Override
    public List funstate1(int id, int page, String state) {
        cs1 cs=new cs1();
        cs.setId(id);
        cs.setPage(page);
        cs.setState(state);
        List list=new ArrayList();
        list.add(cs);
        return list;
    }

    @Override
    public List funstate2(int id, int page, String state,String market_order) {
        cs1 cs=new cs1();
        cs.setId(id);
        cs.setPage(page);
        cs.setState(state);
        cs.setMarketorder(market_order);
        System.out.println("cs1+"+cs);
        List list=new ArrayList();
        list.add(cs);
        System.out.println("list:"+list);
        return list;
    }

    @Override
    public List funstate3(int id, int page) {
        cs1 cs=new cs1();
        cs.setId(id);
        cs.setPage(page);
        cs.setState("全部订单");
        List list=new ArrayList();
        list.add(cs);
        return list;
    }

    @Override
    public int delstate(Map map) {
        int n= dao.delstate(map);
        return n;
    }

    @Override
    public List ddxxlist(Map map) {
        List list=dao.ddxxlist(map);
        return list;
    }
}
